<template>
  <mu-form-item :prop="prop" :label="label" :rules="rules">
    <mu-text-field v-model="showData" @focus="open()" readonly></mu-text-field>
    <dol-cascade-picker
      :value="value"
      :options="options"
      :cascadeLevel="cascadeLevel"
      :slots="slots"
      @input="input"
      @change="change"
      ref="picker"
    />
  </mu-form-item>
</template>

<script>
  export default {
    name: "Dol-cascade-form-item",
    props: {
      value: {type: Array, default: () => []},

      separator: {type: String, default: ' / '},
      label: {type: String, default: ''},
      prop: {type: String, default: ''},
      rules: {type: Array},

      //picker所需参数
      options: {type: Array, default: () => []},
      cascadeLevel: {type: Number, default: 3},
      slots: {type: Array},
    },
    data() {
      return {
        dataMap: [],
        pickerSlots: [],
        pickData: [],
      }
    },
    computed: {
      showData() {
        return this.value.join(this.separator);
      },
    },
    methods: {
      open(){
        this.$refs['picker'].open();
      },
      input(value){
        this.$emit('input', value);
      },
      change(_value, value, index){
        this.$emit('change', _value, value, index);
      },
    },
    created() {
    }
  }
</script>

<style scoped>

</style>
